package cn.tedu.knows.search.repository;

import cn.tedu.knows.search.vo.Item;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface ItemRepository extends
        //继承的父接口ElasticsearchRepository <[vo类型],[id类型]>
        //一旦继承ElasticsearchRepository父接口
        //就像Mybatis Plus一样,自动生成基本的增删改查操作
        ElasticsearchRepository<Item, Long> {

    //自定义查询方法
    //方法名表示要查询的内容
    //      查询 多个item 条件是匹配 title属性
    Iterable<Item> queryItemsByTitleMatches(String title);

    // 多条件查询
    Iterable<Item> queryItemsByTitleMatchesOrBrandMatches(
            String title ,String brand);

    //排序查询
    Iterable<Item>
    queryItemsByTitleMatchesOrBrandMatchesOrderByPriceDesc(
            String title ,String brand);

    //分页查询
    Page<Item>
    queryItemsByTitleMatchesOrBrandMatchesOrderByPriceDesc(
            String title , String brand, Pageable pageable);
}
